package common.stringTest;

import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Map;

public class StringProcess {
    public static void main(String[] args) {
        String s = "";
        System.out.println(isEmpty(s));
    }

    public static boolean isEmpty(Object object) {
        if (object == null) {
            return true;
        } else if (object instanceof CharSequence) {
            return ((CharSequence) object).length() == 0;
        } else if (object.getClass().isArray()) {
            return Array.getLength(object) == 0;
        } else if (object instanceof Collection) {
            return ((Collection<?>) object).isEmpty();
        } else {
            return object instanceof Map && ((Map<?, ?>) object).isEmpty();
        }
    }
}
